<h3><strong>Danh mục | Lĩnh vực: <span id="ten-linh-vuc"><?php echo $TenLV; ?></span></strong></h3>
<table id="tbDanhMuc" class="table table-bordered table-striped bootstrap-datatable datatable">
    <thead>
        <tr>
            <th>Danh mục</th>
            <th>Actions</th>
        </tr>
    </thead>   
    <tbody>
        <?php foreach ($DanhMucs as $DanhMuc) { ?>

            <tr data-id="<?php echo $DanhMuc->Id; ?>">
                <td><a class="editable" href="#" data-name="TenDanhMuc" data-pk="<?php echo $DanhMuc->Id; ?>" data-type="text" data-url="<?php echo Yii::app()->createUrl('admin/default/EditDanhMuc'); ?>"><?php echo $DanhMuc->Ten; ?></a></td>
                <td class="center">
                    <a class="btn btn-danger btn-delete" href="#" title="Xóa Danh mục này">
                        <i class="fa-icon-trash icon-white"></i> 
                    </a>
                </td>
            </tr>
        <?php } ?>
    </tbody>
</table>
<script>
    $(document).ready(function() {
        //turn to inline mode
        $.fn.editable.defaults.mode = 'inline';
        $('.editable').editable({
            onblur: 'submit',
            success: function(data, config) {
                if (data !== 'success') {
                    return data;
                }
            }
        });
        $('.btn-delete').click(function() {
            if (!confirm('Bạn thật sự muốn xóa Danh mục này?')) {
                return;
            }
            var object = $(this).parent().parent();
            var Id = object.attr('data-id');
            URL = '<?php echo Yii::app()->createUrl('admin/default/DeleteDanhMuc'); ?>';
            $.post(URL, {Id: Id}, function(data) {
                if (data === 'success') {
                    object.remove();
                } else {
                    alert(data);
                }
            });
        });
    });
</script>